{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from defs_general import load_config, db\n",
    "from defs_items import q_categories"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "cf = load_config()\n",
    "mc = db(cf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'_id': 'Cucumber',\n",
       "  'desc': 'Makes cats scared',\n",
       "  'opts': ['weight', 'quality', 'shape']},\n",
       " {'_id': 'Tomato',\n",
       "  'desc': 'Is not green',\n",
       "  'opts': ['weight', 'quality', 'color']},\n",
       " {'_id': 'Beef',\n",
       "  'desc': 'Once it said Mooo last time',\n",
       "  'opts': ['weight', 'quality', 'part']}]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ret = []\n",
    "cats = mc['items'].list_collection_names()\n",
    "for cat in cats:\n",
    "  ret += [item for item in mc['items'].get_collection(cat).find({'_id': {'$regex': ''}})]\n",
    "ret"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'_id': 'Cucumber',\n",
       "  'desc': 'Makes cats scared',\n",
       "  'opts': ['weight', 'quality', 'shape']},\n",
       " {'_id': 'Beef',\n",
       "  'desc': 'Once it said Mooo last time',\n",
       "  'opts': ['weight', 'quality', 'part']}]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ret = []\n",
    "cats = mc['items'].list_collection_names()\n",
    "for cat in cats:\n",
    "  ci = mc['items'].get_collection(cat).find({'_id': {'$regex': 'e'}})\n",
    "  for item in ci:\n",
    "    ret.append(item)\n",
    "ret"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'_id': 'foodstuff',\n",
       " 'desc': 'All you can eat or drink',\n",
       " 'subcats': ['greens', 'meat', 'meals', 'beverage', 'liquors'],\n",
       " 'parent': nan}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "q_categories()[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
